import { Button, Node } from "cc";
import { MultiViewComp } from "./MultiViewComp";
import { IView } from "./view/IView";
import { ViewComponent } from "./view/ViewComponent";
import { ViewCtrlBase } from "./view/ViewCtrlBase";



export class MultiViewCtrl extends ViewCtrlBase {

    parseDep(): void {
    }
    get view(): ViewComponent & IView {
        return null;
    }
    get multi(): MultiViewComp {
        return this.node.getComponent(MultiViewComp) as MultiViewComp;
    }
    listClickButtons(): Button[] {
        return null;
    }
    listViewNodeEvent(): string[] {
        return ["node_switchPage"];
    }
    listGlobalEvent(): string[] {
        return null;
    }

    pages: Map<number, Node> = new Map();
    node_switchPage(index: any): void {
        console.log('...... index  ....... ', index);
        const ids = [1, 2, 3, 4];
        const ctrl = this.viewMgr.getCtrl(ids[index]);
        ctrl.create().then((node: Node) => {
            this.multi.content.addChild(node);
            this.pages[index] = node;
        })
    }

}